<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path;
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<title>选课平台-云校通</title>
<jsp:include page="/WEB-INF/page/common/_header.jsp"></jsp:include>
<script src="<%=basePath %>/js/picker.js"></script>
</head>
<body ontouchstart id="wd_xkpt">
    <div class="searchbar_wrap"></div>
    <div id="search-content" style="height: 100%;z-index: 10;position:relation;display: none;">
       <div class="sb-content" style="overflow:scroll;">
      		
       </div>
    </div>
    <!--下拉选择-->
	<div class="page-bd top-category"> 
		<ul>
			<li class="">
				<div class="weui-flex js-category">
					<p class="weui-flex-item tcenter">2016-2017 学年上学期 <i class="icon icon-74"></i></p>
				</div>
				<div class="page-category page-category2 js-categoryInner">
			
					<div class="weui_cells weui_cells_access" style="margin-top: 0px;">
						<a class="weui_cell" href="javascript:;">
							<div class="weui_cell_bd weui_cell_primary">
								<p class="f-blue">2016-2017学年上学期 <i class="icon right f-green icon-66"></i></p>
								
							</div>
						</a>
						<a class="weui_cell" href="javascript:;">
							<div class="weui_cell_bd weui_cell_primary">
								<p>2015-2016学年下学期</p>
							</div>
							<div class="weui_cell_ft"></div>
						</a>
					</div>
				</div>
			</li>
		</ul>
	</div>
	<!--End下拉选择-->
    
	<div class="weui_panel weui_panel_access" style="margin-top: 0;">
       <div class="weui_panel_bd" id="studentList">
       		<div class="mui-card">
	        	<div class="weui_cells">
					<div class="weui_cell">
						<div class="weui_cell_hd ">
							<img class="circle" src="<%=basePath %>/images/siliao_touxiang@3x.png" alt="" style="width:30px;margin-right:10px;display:block">
						</div>
						<div class="weui_cell_bd weui_cell_primary">
							<p>欧阳锋</p>
						</div>
						<div class="weui_cell_ft">
							<!--<a class="f-black" style="margin-right: 15px;" href="cx.html"><img width="18" src="<%=basePath %>/images/chongxuan@3x.png"/> 重选</a>
							<a class="f-black" href="cx.html"><img width="18" src="<%=basePath %>/images/tiaoban@3x.png"/> 调班</a>-->
							<a href="javascript:;" class="weui_btn weui_btn_mini weui_btn_primary bg-blue btn">修改</a>
						</div>
					</div>
					<div class="weui_cell xkpt-lesson">
						<div class="weui_cell_bd weui_cell_primary">
							<p>课程名称</p>
						</div>
						<div class="weui_cell_ft">
							沙画
						</div>
						<input type="text" class="xkpt-lesson-input" class="">
					</div>
					<div class="weui_cell">
						<div class="weui_cell_bd weui_cell_primary">
							<p>上课老师</p>
						</div>
						<div class="weui_cell_ft">
							孙俊豪
						</div>
					</div>
					<div class="weui_cell">
						<div class="weui_cell_bd weui_cell_primary">
							<p>上课地点</p>
						</div>
						<div class="weui_cell_ft">
							到顺右面地霏百味晨登峰街道
						</div>
					</div>
				</div>
	        </div>
	        <div class="mui-card">
	        	<div class="weui_cells">
					<div class="weui_cell">
						<div class="weui_cell_hd ">
							<img class="circle" src="<%=basePath %>/images/siliao_touxiang@3x.png" alt="" style="width:30px;margin-right:10px;display:block">
						</div>
						<div class="weui_cell_bd weui_cell_primary">
							<p>课程名称</p>
						</div>
						<div class="weui_cell_ft">
							<a href="javascript:;" class="weui_btn weui_btn_mini weui_btn_primary bg-blue btn">修改</a>
						</div>
					</div>
					<div class="weui_cell xkpt-lesson">
						<div class="weui_cell_bd weui_cell_primary">
							<p>课程名称</p>
						</div>
						<div class="weui_cell_ft">
							沙画
						</div>
						<input type="text" class="xkpt-lesson-input" class="">
					</div>
					<div class="weui_cell">
						<div class="weui_cell_bd weui_cell_primary">
							<p>上课老师</p>
						</div>
						<div class="weui_cell_ft">
							孙俊豪
						</div>
					</div>
					<div class="weui_cell">
						<div class="weui_cell_bd weui_cell_primary">
							<p>上课地点</p>
						</div>
						<div class="weui_cell_ft">
							到顺右面地霏百味晨登峰街道
						</div>
					</div>
				</div>
	        </div>
       </div>
    </div>
	<jsp:include page="/WEB-INF/page/common/_footer.jsp"></jsp:include>
	<script>
		$(function(){
	 		$('.searchbar_wrap').searchBar({
				cancelText: "取消",
				searchText: '请输入学生姓名',
				onfocus: function(value) {
					$("#search-content").show();
					$(".weui_panel").hide();
				},
				onblur: function(value) {
				},
				input: function(value) {
					queryItem(value);
				},
				onsubmit: function(value) {
					queryItem(value);
				},
				oncancel: function() {
					$("#search-content").hide();
					$(".weui_panel").show();
					$(".sb-content").html('');
				},
				onclear: function() {
					$(".sb-content").html('');
					$("#search-content").hide();
					$(".weui_panel").show();
				}
			});
	 		
	 		$('.js-category').click(function() {
				$parent = $(this).parent('li');
				if($parent.hasClass('js-show')) {
					$(".maskAll").hide();
					$parent.removeClass('js-show');
					$(this).children('i').removeClass('icon-35').addClass('icon-74');
				} else {
					$(".maskAll").show();
					$parent.siblings().removeClass('js-show');
					$parent.addClass('js-show');
					$(this).children('i').removeClass('icon-74').addClass('icon-35');
					$parent.siblings().find('i').removeClass('icon-35').addClass('icon-74');
				}
			});
			
			$(".btn").click(function(){
				var obj = $(this);
				var objOuter = obj.closest(".weui_cells");
				if(obj.hasClass("isChange")){
					obj.text("修改");
					obj.removeClass("isChange");
					objOuter.find(".xkpt-lesson").removeClass("weui_cells_access");
					objOuter.find(".xkpt-lesson-input").removeClass("on");
				}else{
					obj.addClass("isChange");
					obj.text("保存");
					objOuter.find(".xkpt-lesson").addClass("weui_cells_access");
					objOuter.find(".xkpt-lesson-input").addClass("on");
				}
			})
			
			$(".xkpt-lesson-input").picker({
		        title: "请选择课程",
		        toolbarCloseText:'确定',
		        onClose:function(){
		        	$(this.input).closest(".xkpt-lesson").find(".weui_cell_ft").text(this.cols[0].displayValue);
		        },
		        cols: [
		          {
		            textAlign: 'center',
		            values: [1,2,3],
		            displayValues:['沙画1','沙画2','沙画3'],
		          }
		        ]
		    });

	 		var page = 0;
			var size = 20;
		    /* $('.weui_panel').dropload({
		        scrollArea : window,
		        autoLoad : true,//自动加载
		        domDown : {//上拉
		            domClass   : 'dropload-down',
		            domRefresh : '<div class="dropload-refresh f15 "><i class="icon icon-20"></i>上拉加载更多</div>',
		            domLoad    : '<div class="dropload-load f15"><span class="weui-loading"></span>正在加载中...</div>',
		            domNoData  : '<div class="dropload-noData">没有更多数据了</div>'
		        },
		        domUp : {//下拉
		            domClass   : 'dropload-up',
		            domRefresh : '<div class="dropload-refresh"><i class="icon icon-114"></i>上拉加载更多</div>',
		            domUpdate  : '<div class="dropload-load f15"><i class="icon icon-20"></i>松手开始加载...</div>',
		            domLoad    : '<div class="dropload-load f15"><span class="weui-loading"></span>正在加载中...</div>'
		        },
		        loadDownFn : function(me){//加载更多
		        	page++;
		        	var params = {
	        			page: page,
		    			rows: size,
		    			grade: "${model.grade}",
		    			clazz: "${model.clazz}"
	    			};
	    			$.ajax({
	    	          	url : basePath + "/ls/students/manage/page/query",
	    	  	 		type : "post",
	    	  	 		dataType : "json",
	    	  	 		data : params,
	    	            success: function(data){
	             		  if(data.rows.length == 0 || page*size >= data.total) {// 如果没有数据
	             			// 锁定
		                      me.lock();
		                      // 无数据
		                      me.noData();
	                      }
	             		  setTimeout(function(){
	             			 loadItemHtml(data);
		                      // 每次数据加载完，必须重置
	             			 me.resetload();
	             		  },200);
	                  },
	                  error: function(xhr, type){
	                  }
	              });      
		        }
		    }); */
		});
		function loadItemHtml(data) {
			var html = "";
			for(var i in data.rows) {
				var itm = data.rows[i];
				html += '<div class="weui_cell">';
				html += '<div class="weui_cell_hd"><img class="circle bg-blue-b" src="<%=basePath%>/<%=basePath %>/images/siliao_touxiang@3x.png" style="width:50px;margin-right:20px;display:block"></div>';
				html += '<div class="weui_cell_bd weui_cell_primary"><p>' + itm.name + '</p>';
				if(itm.parentCount == null) {
					html += '<p style="color: #888888; font-size: 13px;">未绑定微信</p>';
				}
				html += '</div><div class="weui_cell_ft">';
	            if("${model.clazz}" != "" && itm.parentCount != null) {
	            	html += '<span><a href="<%=basePath%>/ls/groupChat/class/sx?sid='+ itm.id +'" class="weui_btn weui_btn_mini bg-blue-b">私信</a></span>';
	            }
	            html += '<span class="ml10"><a href="<%=basePath %>/ls/students/manage/info/query/' + itm.id + '"class="weui_btn weui_btn_mini bg-blue-b">修改</a></span>';
	            html += '</div></div>';
			}
			$("#studentList").append(html);
		}
		var seach = false;
		function queryItem(keyword) {
			if(!/^[\u4E00-\u9FA5]+$/.test(keyword)) return;
			if(seach) return;
			seach = true;
			$.ajax({
	    		url: basePath + "/ls/students/manage/keyword",
	    		type: 'POST',
	    		dataType : "json",
	    		data: {
	    			grade: "${model.grade}",
	    			clazz: "${model.clazz}",
	    			studentName: keyword
	    		},
	    		success: function(data) {
	    			seach = false;
	    			if (data != null && data.length > 0) {
	    				var html = "";
	    				for(var i in data) {
	    					var itm = data[i];
	            			html += '<div class="weui_cell">';
	    					html += '<div class="weui_cell_bd weui_cell_primary"><p>' + itm.name + '</p>';
	    					if(itm.parentCount == null) {
	    						html += '<p style="color: #888888; font-size: 13px;">未绑定微信</p>';
	    					}
	    					html += '</div><div class="weui_cell_ft">';
		    	            if("${model.clazz}" != "" && itm.parentCount != null) {
		    	            	html += '<span><a href="<%=basePath%>/ls/groupChat/class/sx?sid='+ itm.id +'" class="weui_btn weui_btn_mini bg-blue-b">私信</a></span>';
		    	            }
		    	            html += '<span class="ml10"><a href="<%=basePath %>/ls/students/manage/info/query/' + itm.id + '"class="weui_btn weui_btn_mini bg-blue-b">修改</a></span>';
		    	            html += '</div></div>';
	    				}
	    				$(".sb-content").html(html);
	    			}
	    		},
	    		error: function(data) {
	    			alert("系统异常,请联系管理员");
	    		}
	    	});
		}
	</script>
</body>
</html>